//width->300 height->500  data-> {width:300,height:500}
function startMove(domobj, data, fn) {
  clearInterval(domobj.timer);
  domobj.timer = setInterval(() => {
    //考虑到了使用循环\
    let count = 0;
    for (let cssAttr in data) {
      let iCur;
      if (cssAttr == "opacity") {
        //为啥*100,因为透明度的取值0-1，直接用这个值，不会出现持续变化效果
        iCur = parseInt(getComputedStyle(domobj)[cssAttr] * 100);
      } else {
        iCur = parseInt(getComputedStyle(domobj)[cssAttr]);
      }

      let iTar = data[cssAttr]; //目标值
      let iSpeed = (iTar - iCur) / 8;
      iSpeed = iSpeed > 0 ? Math.ceil(iSpeed) : Math.floor(iSpeed);

      if (cssAttr == "opacity") {
        domobj.style.opacity = (iCur + iSpeed) / 100;
      } else {
        domobj.style[cssAttr] = iCur + iSpeed + "px";
      }

      if (iSpeed == 0) {
        count++;
      }
    }
    //Object.keys(data)得到一个对象的所有键名的一个数组
    // console.log(Object.keys(data))
    // console.log(Object.values(data))
    if (count == Object.keys(data).length) {
      clearInterval(domobj.timer);
      if (fn) {
        fn();
      }
    }
  }, 20);
}
